/**
 * @file
 * @author  Alejandro Castano del Castillo <alecastanyo@gmail.com>
 * @version 0.0.1
 *
 * @section LICENSE
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details at
 * http://www.gnu.org/copyleft/gpl.html
 *
 * @section DESCRIPTION
 *
 * The time class represents a moment of time.
 */

#ifndef _RENDERMANAGER_H
#define _RENDERMANAGER_H


#include "textureloader.h"
#include "color.h"
#include "box.h"
//#include "../core/vector3.h"

#include <string>

class RenderManager
{
  public:
    RenderManager();
    virtual ~RenderManager();

    virtual bool load()=0;

    /////////////////////////////
    /// DRAW-FUNCTIONS
    /// All this functions are used to draw in the screen
    /////////////////////////////

    /**
      * Draw a texture in the coordenates
      *
      * @param id is the texture's identification number
      * @param box is the coordenates where the texture is,
      * it's not where the texture is gonna be drawn. @see camera?
      */
    void blitTexture(TextureID texture,Box& box);

    /**
      * Draw a pixel.
      *
      * @param color is the color.
      * @param point is the coordenates where it is.
      */
    //virtual void putPixel(Color color,Vector3 point)=0;

    // Background
    /** 
      * Set the color of the background. It's the first in to be drawn.
      */
    void setBackgroundColor(Color& c);
    /**
      * Set the texture is going to be draw after the background color
      * and before something more.
      */
    void setBackgroundTexture(std::string path);

    /**
      * Unset the texture and set the color in black.
      */
    void unloadBackground();
    
    /**
      * @returns true if the actual screen is fullcreen.
      */
    virtual bool getFullscreen();
    /**
      * Change the actual state of the screen. SDL only can do this in some
      * systems. The new value is saved in Settings, so if it saves
      * the next time the application will start with the new value.
      *
      * @returns true if the actual state of the screen is the same of
      * the param f.
      */
    virtual bool setFullscreen(bool f);

    virtual void draw()=0;

  protected:

    virtual void clean();

    typedef queue<Box> QuadsList;
    typedef QuadsList::it QuadsIt;

    typedef queue<TextureID> TextureList;
    typedef TextureList::iterator TextureIt;

    QuadsList m_quads;
    TextureList m_textureQuads;

    bool m_fullscreen;
    Color m_backgroundColor;
    TextureID m_background;
};

#endif
